﻿using System;
using System.Linq;
using SimpleForum.Data.Services;

namespace SimpleForum.Classes.Achievements
{
    public class ComedianAchievement : AchievementWorker
    {
        public ComedianAchievement() : base() { }

        protected override void AwardAchievement()
        {
            var UserService = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<UserService>();
            var Users = UserService.GetUsers().ToList();

            foreach (var User in Users)
            {
                if (User.PostRatings.Where(x => x.RatingName == "Funny").Count() >= 100) UserService.GiveAchievement(User.Id, UserService.AchievementType.ComedianAchievement);
            }
        }

        protected override TimeSpan Interval
        {
            get
            {
                return new TimeSpan(1, 0, 0);
            }
        }
    }
}